import 'babel-polyfill'

import Vue from 'vue'
import 'jquery';
import App from './App'
import axios from 'axios'
import Lockr from 'lockr'
import Cookies from 'js-cookie'
import _ from 'lodash'
import moment from 'moment'
import ElementUI from 'element-ui'
// import '../theme/index.css'
// import 'element-ui/lib/theme-default/index.css'
import 'element-ui/lib/theme-chalk/index.css'
import routes from './routes'
import VueRouter from 'vue-router'
import store from './vuex/store'
import filter from './assets/js/filter'
import _g from './assets/js/global'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import 'assets/css/global.css'
import 'assets/css/base.css'
import 'assets/css/animate.css'

import VueContextMenu from 'vue-contextmenu'
import 'vue-contextmenu/style/css/font-awesome.min.css'
import echarts from 'echarts'

import * as filters from './filters'
import directive from './assets/js/directive'



axios.defaults.baseURL = HOST
axios.defaults.timeout = 1000 * 15
axios.defaults.headers.token = Lockr.get('token')
axios.defaults.headers.sessionId = Lockr.get('sessionId')
axios.defaults.headers['Content-Type'] = 'application/json'

const router = new VueRouter({
  mode: 'history',
  // base: __dirname,
  base: WEB_ROOT,
  routes
})
router.beforeEach((to, from, next) => {
  const hideLeft = to.meta.hideLeft
  store.dispatch('showLeftMenu', hideLeft)
  // store.dispatch('showLoading', true);
  NProgress.start()
  next()
})

router.afterEach(transition => {
  NProgress.done()
})

Vue.use(ElementUI,{size: 'small'});
Vue.use(VueRouter)

Vue.use(VueContextMenu)

Vue.filter('date', filters.dateFilter)

Vue.use(echarts);
Vue.prototype.$echarts = echarts

window.WEB_ROOT = WEB_ROOT
window.router = router
window.store = store
window.HOST = HOST
window.axios = axios
window._ = _
window.moment = moment
window.Lockr = Lockr
window.Cookies = Cookies
window._g = _g
window.pageSize = 15
const bus = new Vue()
window.bus = bus
//setting
window.SysSetting = new Promise((resolve,reject)=>{

    axios.get("login/getSetting").then(resp=>{
      if(resolve){
        if(resp && resp.data.code == 200)
        console.log(resp.data.data);
        resolve(resp.data.data);
      }else{
        reject(resp.data);
      }
    }).catch(error=>{
        reject(error);
    });
});
// 
new Vue({
  el: '#app',
  template: '<App/>',
  filters : filter,
  router,
  store,
  components: { App }
// render: h => h(Login)
}).$mount('#app')
